<html>
<html>
<head>
<title>iCUP - Beheer</title>
<!--<meta http-equiv="X-UA-Compatible" content="IE=8" />-->
<link rel="stylesheet" type="text/css" href="style.css" />
<link rel="stylesheet" type="text/css" href="hourtable.css" />
<link rel="stylesheet" type="text/css" href="Buttons.css" />
<script type="text/javascript" src="funcs.js"></script>
<script type="text/javascript" src="selectivizr.js"></script>
</head>
<body>
<?php



require("dbconn.php");

	$week = 52;
	$QUERY = "
		SELECT DISTINCT id, uur, dag
		FROM studieuur
		WHERE id IN
		(
			SELECT studieuur
			FROM studieuurklas
		)
	";
	//echo $QUERY;
	$resultheader = mysql_query($QUERY);
	$columns = mysql_numrows($resultheader);


	
?><table cellspacing="0" align="left" valign="top">
	<tr>
		<td colspan="<?php print(mysql_numrows($resultheader)); ?>">
			<h1>Beheer docenten: <input id="reloadteachermanagment" type="text" value="alle leraren" style="color: gray;" onfocus="if (this.value == 'alle leraren') { this.value = ''; this.style.color = 'black'; }" onblur="if (this.value == '') { this.value = 'alle leraren'; this.style.color = 'gray'; }" /></h1>
		</td>
	</tr>
	<tr style="vertical-align: top;">
<?php



	for($i = 0; $i < $columns; $i++)
	{
		$header = mysql_result($resultheader, $i, "dag") . mysql_result($resultheader, $i, "uur"); // de manier waarop je info uit de db haalt
		$sid = mysql_result($resultheader, $i, "id");
		
		$QUERY = "
			SELECT docentid
			FROM docent
			WHERE docentid IN
			(
				SELECT docentid
				FROM docentcluster
				WHERE cluster IN
				(
					SELECT klas 
					FROM studieuurklas
					WHERE studieuur = '$sid'
				)
			)
		";
			
		$resultdata = mysql_query($QUERY) or die (mysql_error());
		$rows = mysql_numrows($resultdata);
		
		
?>		<td>
			<table id="<?php $rnd = mt_rand(10, 99); print($rnd); ?>" cellspacing="0" align="left" valign="top" class="hourtable">
				<tr>
					<th class="uur" colspan="4">
						<?php print($header); ?> 
					</th>
				</tr>
<?php



		for($j=0; $j < $rows; $j++)
		{
			$datadocentid = mysql_result($resultdata, $j, "docentid");
			
			$QUERY = "
				SELECT cluster
				FROM docentcluster
				WHERE docentid = '$datadocentid'
				AND cluster IN
				(
					SELECT klas 
					FROM studieuurklas
					WHERE studieuur = '$sid'
				)
			";
			
		$resultdata2 = mysql_query($QUERY) or die (mysql_error());
		$datacluster = "";
			for ($k=0; $k < mysql_numrows($resultdata2); $k++)
			{
				$datacluster .= mysql_result($resultdata2, $k, "cluster") . " ";
			}
			
			
			
?>				<tr>
					<td id="<?php print($i . $j); ?>">
						<?php print($datadocentid); ?>
					</td>
					<td>
						<?php print($datacluster); ?>
					</td>
					<td>
						<a class="actionbutton" onclick="delplacefromweek('<?php print("$sid"); ?>', '<?php print("$plaatsnr"); ?>')"><img src="pics/delweek.png" /></a>
					</td>
				</tr>
<?php


		}
		
		
?>				<tr>
					<td colspan="3" style="border-top: 2px solid black; border-right: 2px solid black; width: 100px !important;">
						voeg toe...
					</td>
					<td style="border-top: 2px solid black; width: 20px !important;">
						<a onclick="document.getElementById('adder_<?php print($header); ?>').style.display = document.getElementById('choser_<?php print($header); ?>').style.display = (document.getElementById('choser_<?php print($header); ?>').style.display == 'table-row') ? 'none' : 'table-row'; document.getElementById('choosebtn_<?php print($header); ?>').src = (document.getElementById('choser_<?php print($header); ?>').style.display == 'table-row') ? 'pics/exphider.png' : 'pics/expchoser.png';" class="actionbutton"><img src="pics/expchoser.png" id="choosebtn_<?php print($header); ?>" /></a>
					</td>
				</tr>
				<tr style="display: none;" id="adder_<?php print($header); ?>" class="adder">
					<td>
						<input type="text" maxlength="2" id="addHourSubject_<?php print("$header"); ?>" style="font-size: 12px; margin: 0; padding: 0; width: 90%;" onkeyup="reloadHoursChoser('<?php print("$header"); ?>', '<?php print("$sid"); ?>');" />
					</td>
					<td>
						<input type="text" maxlength="3" id="addHourTeacher_<?php print("$header"); ?>" style="font-size: 12px; margin: 0; padding: 0; width: 90%;" onkeyup="reloadHoursChoser('<?php print("$header"); ?>', '<?php print("$sid"); ?>');" />
					</td>
					<td>
						<input type="text" maxlength="3" id="addHourRoomNr_<?php print("$header"); ?>" style="font-size: 12px; margin: 0; padding: 0; width: 90%;" onkeyup="reloadHoursChoser('<?php print("$header"); ?>', '<?php print("$sid"); ?>');" />
					</td>
					<td>
						<a class="actionbutton" onclick="clearadderfield('<?php print("$header"); ?>'); reloadHoursChoser('<?php print("$header"); ?>', '<?php print("$sid"); ?>');"><input type="image" src="pics/delweek.png" /></a>
					</td>
				</tr>
				<tr style="display: none;" id="choser_<?php print($header); ?>">
					<td colspan="5" style="border-top: 2px solid black;">
<?php



require("getteachersChoser.php");



?>					</td>
				</tr>
			</table>
		</td>
<?php



	}
	
	
	
?>	</tr>
</table>
</body>